/*
 * @Author: 肖芬芳 10547202+xiao-fenfang@user.noreply.gitee.com
 * @Date: 2022-06-17 09:05:52
 * @LastEditors: 肖芬芳 1911683843@qq.com
 * @LastEditTime: 2022-12-09 09:40:02
 * @FilePath: \kindstar-youyi-webc:\Users\Administrator\Desktop\vue-api-server\app.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const express = require('express');
const app = express();
const formidable = require('express-formidable');
const path = require('path');
// 引入session模块
var session = require('express-session');

// 引入数据库模块
require('./model/connect.js');
const User = require('./model/user.js');
const Role = require('./model/role.js');
const FirstClass=require("./model/goodFirstClass.js")
const SecondClass=require("./model/goodSecondClass.js")

// formidable获取post参数，可以获取文件req.files，可以获取其他req.fields
app.use(formidable({
    encoding: 'utf-8',
    //图形文件存储在uploads里面
    uploadDir: path.join(__dirname, 'public', 'uploads'),
    multiples: true, // req.files to be arrays of files
    keepExtensions: true
}));


// session配置
// 目的1：存储登录信息，防止未登录跳转
app.use(session({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: false
}));

// 模块化路由
require('./routes')(app);
app.listen(4000, () => {
    console.log('服务器连接成功！')
})